package com.serverTechnology.teamsGroups.controller;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import javax.annotation.Resource;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.serverTechnology.teamsGroups.entity.dto.GroupUserDto;
import com.serverTechnology.teamsGroups.entity.dto.TeamsGroupAddDto;
import com.serverTechnology.teamsGroups.entity.dto.TeamsGroupEditDto;
import com.serverTechnology.teamsGroups.entity.vo.TeamsGroupAddVo;
import com.serverTechnology.teamsGroups.entity.dto.TeamsGroupDto;
import com.serverTechnology.teamsGroups.entity.vo.TeamsGroupDetailsVo;
import com.serverTechnology.teamsGroups.entity.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.serverTechnology.teamsGroups.service.ITeamsGroupService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;


/**
 * 班组表 接口
 *
 * @author 王凯炫
 * @since 2024-07-28
 */
@RestController
@ApiResource(name = "班组表的接口")
@Api(tags = "班组管理")
public class TeamsGroupController {

    @Resource(name = "TeamsGroupServiceImpl")
    private ITeamsGroupService iTeamsGroupService;



    /**
     * 添加班组表
     */
    @PostResource(name = "添加班组表", path = "/teamsGroup/add")
    @ApiOperation(value = "添加班组表")
    public ResponseData add(@RequestBody @Validated TeamsGroupAddDto teamsGroup){
        iTeamsGroupService.add(teamsGroup);
        return new SuccessResponseData<>("添加成功");
    }

    /**
     * 查询人员详情
     * @param
     * @return
     */
    @GetResource(name="人员详情",path = "/teamsGroup/detail")
    @ApiOperation(value = "人员详情")
    public ResponseData<PageResult<UserVo>> selectuser(){
        return new SuccessResponseData<>(iTeamsGroupService.selectuser());
    }

    /**
     * 删除班组
     */
    @GetResource(name = "删除班组人员", path = "/teamsGroup/delete")
    @ApiOperation(value = "删除班组人员")
    public ResponseData delete(Long  id){
        iTeamsGroupService.del(id);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑班组表
     */
    @PostResource(name = "编辑班组表", path = "/teamsGroup/edit")
    @ApiOperation(value = "编辑班组表")
    public ResponseData edit(@RequestBody @Validated TeamsGroupEditDto teamsGroup) {
        iTeamsGroupService.edit(teamsGroup);
        return new SuccessResponseData<>();
    }

    /**
     * 查询班组详情
     * @param id
     * @return
     */
    @GetResource(name = "查询班组详情", path = "/teamsGroup/sele")
    @ApiOperation(value = "查询班组详情")
    public ResponseData<TeamsGroupDetailsVo> sele(Long id) {
        return new SuccessResponseData<>(iTeamsGroupService.sele(id));
    }

    /**
     * 分页查询-班组表列表
     */
    @GetResource(name = "分页查询-班组表列表", path = "/teamsGroup/page")
    @ApiOperation(value = "分页查询班组表列表")
    public ResponseData<Page<TeamsGroupAddVo>> page(TeamsGroupDto teamsGroup) throws ParseException {
        return new SuccessResponseData<>(iTeamsGroupService.findPage(teamsGroup));
    }

    /**
     * 选择班长
     * @param groupUserDto
     * @return
     */
    @PostResource(name = "选择班长", path = "/teamsGroup/monitor")
    @ApiOperation(value = "选择班长")
    public ResponseData monitor(@RequestBody @Validated GroupUserDto groupUserDto) {
        iTeamsGroupService.editMonitor(groupUserDto);
        return new SuccessResponseData<>();
    }

}
